package com.chunuo.eduservice.controller;


import com.chunuo.commonutils.R;
import com.chunuo.eduservice.entity.EduVideo;
import com.chunuo.eduservice.service.EduVideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 课程视频 前端控制器
 * </p>
 *
 * @author testjava
 * @since 2020-07-04
 */
@RestController
@RequestMapping("/eduservice/edu-video")
//@CrossOrigin
public class EduVideoController {

    @Autowired
    private EduVideoService eduVideoService;

    @PostMapping("/save")
    public R save(@RequestBody EduVideo eduVideo){
        eduVideoService.save(eduVideo);
        return R.ok();
    }

    @PutMapping("/edit")
    public R update(@RequestBody EduVideo eduVideo){
        eduVideoService.updateById(eduVideo);
        return R.ok();
    }

    @GetMapping("/info/{id}")
    public R info(@PathVariable("id")String id){
        EduVideo info = eduVideoService.getById(id);
        return R.ok().data("info",info);
    }

    @DeleteMapping("/delete/{id}")
    public R delete(@PathVariable("id")String id){
        eduVideoService.deleteVideo(id);
        return R.ok();
    }


}

